﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __DDEBA1E4_A5BF_41CF_8D2C_0D2BC94F37F8__
#define __DDEBA1E4_A5BF_41CF_8D2C_0D2BC94F37F8__

#include "i_variant.h"

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace xos_box
{

    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    // 
    // property
    // 
    class i_property : public xos::i_release
    {
    public:
        virtual ~i_property(){}

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 
        // name index
        // 

        virtual const char * str( const char * lpszName, char * lpszValue = 0, int nBufSize = 0, int * lpnSizeNeeded = 0 ) = 0;
        virtual xos::i_release * obj( const char * lpszName, xos::i_release ** ppv = 0 ) = 0;
        virtual xos_box::i_list * list( const char * lpszName, xos_box::i_list ** ppv = 0 ) = 0;
        virtual i_property * prop( const char * lpszName, i_property ** ppv = 0 ) = 0;
        virtual v_create fun( const char * lpszName, v_create * pv = 0 ) = 0;
        virtual double dbl( const char * lpszName, double * lpdValue = 0 ) = 0;
        virtual float flt( const char * lpszName, float * lpfValue = 0 ) = 0;
        virtual int it( const char * lpszName, int  * lpnValue = 0 ) = 0;

        virtual xos::xos_u64 * u64_ptr( const char * lpszName, xos::xos_u64 ** lppRet = 0 ) = 0;
        virtual xos::xos_i64 * i64_ptr( const char * lpszName, xos::xos_i64 ** lppRet = 0 ) = 0;
        virtual xos::xos_u32 * u32_ptr( const char * lpszName, xos::xos_u32 ** lppRet = 0 ) = 0;
        virtual xos::xos_i32 * i32_ptr( const char * lpszName, xos::xos_i32 ** lppRet = 0 ) = 0;
        virtual xos::xos_u16 * u16_ptr( const char * lpszName, xos::xos_u16 ** lppRet = 0 ) = 0;
        virtual xos::xos_i16 * i16_ptr( const char * lpszName, xos::xos_i16 ** lppRet = 0 ) = 0;
        virtual xos::xos_u8 * u8_ptr( const char * lpszName, xos::xos_u8 ** lppRet = 0 ) = 0;
        virtual xos::xos_i8 * i8_ptr( const char * lpszName, xos::xos_i8 ** lppRet = 0 ) = 0;
        virtual char * char_array( const char * lpszName, char ** lppRet = 0, int * lpnSize = 0, int * lpnLen = 0 ) = 0;
        virtual char * bin_ptr( const char * lpszName, char ** lppRet = 0, int * lpnSize = 0, int * lpnLen = 0 ) = 0;
        virtual double * dbl_ptr( const char * lpszName, double ** lppRet = 0 ) = 0;
        virtual float * flt_ptr( const char * lpszName, float ** lppRet = 0 ) = 0;
        virtual bool * bool_ptr( const char * lpszName, bool ** lppRet = 0 ) = 0;

        virtual int set( const char * lpszName, const char * lpszValue ) = 0;
        virtual int set_obj( const char * lpszName, xos::i_release * pv, bool bAutoRelease ) = 0;
        virtual int set_list( const char * lpszName, xos_box::i_list * pv, bool bAutoRelease ) = 0;
        virtual int set_prop( const char * lpszName, i_property * pv, bool bAutoRelease ) = 0;
        virtual int set( const char * lpszName, i_variant * pv ) = 0;
        virtual int set( const char * lpszName, v_create pv ) = 0;
        virtual int set( const char * lpszName, double value ) = 0;
        virtual int set( const char * lpszName, float value ) = 0;
        virtual int set( const char * lpszName, int value ) = 0;

        virtual int set( const char * lpszName, xos::xos_u64 * lpRef ) = 0;
        virtual int set( const char * lpszName, xos::xos_i64 * lpRef ) = 0;
        virtual int set( const char * lpszName, xos::xos_u32 * lpRef ) = 0;
        virtual int set( const char * lpszName, xos::xos_i32 * lpRef ) = 0;
        virtual int set( const char * lpszName, xos::xos_u16 * lpRef ) = 0;
        virtual int set( const char * lpszName, xos::xos_i16 * lpRef ) = 0;
        virtual int set_u8( const char * lpszName, xos::xos_u8 * lpRef ) = 0;
        virtual int set_i8( const char * lpszName, xos::xos_i8 * lpRef ) = 0;
        virtual int set_char_array( const char * lpszName, char * lpRef, int nBufSize ) = 0;
        virtual int set_bin( const char * lpszName, char * lpRef, int nBufSize ) = 0;
        virtual int set( const char * lpszName, double * lpRef ) = 0;
        virtual int set( const char * lpszName, float * lpRef ) = 0;
        virtual int set( const char * lpszName, bool * lpRef ) = 0;

        virtual i_variant * remove( const char * lpszName ) = 0;
        virtual i_variant * vt( const char * lpszName ) = 0;

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 
        // id index
        // 

        virtual const char * str( int nId, char * lpszValue = 0, int nBufSize = 0, int * lpnSizeNeeded = 0 ) = 0;
        virtual xos::i_release * obj( int nId, xos::i_release ** ppv = 0 ) = 0;
        virtual xos_box::i_list * list( int nId, xos_box::i_list ** ppv = 0 ) = 0;
        virtual i_property * prop( int nId, i_property ** ppv = 0 ) = 0;
        virtual v_create fun( int nId, v_create * pv = 0 ) = 0;
        virtual double dbl( int nId, double * lpdValue = 0 ) = 0;
        virtual float flt( int nId, float * lpfValue = 0 ) = 0;
        virtual int it( int nId, int  * lpnValue = 0 ) = 0;

        virtual xos::xos_u64 * u64_ptr( int nId, xos::xos_u64 ** lppRet = 0 ) = 0;
        virtual xos::xos_i64 * i64_ptr( int nId, xos::xos_i64 ** lppRet = 0 ) = 0;
        virtual xos::xos_u32 * u32_ptr( int nId, xos::xos_u32 ** lppRet = 0 ) = 0;
        virtual xos::xos_i32 * i32_ptr( int nId, xos::xos_i32 ** lppRet = 0 ) = 0;
        virtual xos::xos_u16 * u16_ptr( int nId, xos::xos_u16 ** lppRet = 0 ) = 0;
        virtual xos::xos_i16 * i16_ptr( int nId, xos::xos_i16 ** lppRet = 0 ) = 0;
        virtual xos::xos_u8 * u8_ptr( int nId, xos::xos_u8 ** lppRet = 0 ) = 0;
        virtual xos::xos_i8 * i8_ptr( int nId, xos::xos_i8 ** lppRet = 0 ) = 0;
        virtual char * char_array( int nId, char ** lppRet = 0, int * lpnSize = 0, int * lpnLen = 0 ) = 0;
        virtual char * bin_ptr( int nId, char ** lppRet = 0, int * lpnSize = 0, int * lpnLen = 0 ) = 0;
        virtual double * dbl_ptr( int nId, double ** lppRet = 0 ) = 0;
        virtual float * flt_ptr( int nId, float ** lppRet = 0 ) = 0;
        virtual bool * bool_ptr( int nId, bool ** lppRet = 0 ) = 0;

        virtual int set( int nId, const char * lpszValue ) = 0;
        virtual int set_obj( int nId, xos::i_release * pv, bool bAutoRelease ) = 0;
        virtual int set_list( int nId, xos_box::i_list * pv, bool bAutoRelease ) = 0;
        virtual int set_prop( int nId, i_property * pv, bool bAutoRelease ) = 0;
        virtual int set( int nId, i_variant * pv ) = 0;
        virtual int set( int nId, v_create pv ) = 0;
        virtual int set( int nId, double value ) = 0;
        virtual int set( int nId, float value ) = 0;
        virtual int set( int nId, int value ) = 0;

        virtual int set( int nId, xos::xos_u64 * lpRef ) = 0;
        virtual int set( int nId, xos::xos_i64 * lpRef ) = 0;
        virtual int set( int nId, xos::xos_u32 * lpRef ) = 0;
        virtual int set( int nId, xos::xos_i32 * lpRef ) = 0;
        virtual int set( int nId, xos::xos_u16 * lpRef ) = 0;
        virtual int set( int nId, xos::xos_i16 * lpRef ) = 0;
        virtual int set_u8( int nId, xos::xos_u8 * lpRef ) = 0;
        virtual int set_i8( int nId, xos::xos_i8 * lpRef ) = 0;
        virtual int set_char_array( int nId, char * lpRef, int nBufSize ) = 0;
        virtual int set_bin( int nId, char * lpRef, int nBufSize ) = 0;
        virtual int set( int nId, double * lpRef ) = 0;
        virtual int set( int nId, float * lpRef ) = 0;
        virtual int set( int nId, bool * lpRef ) = 0;

        virtual i_variant * remove( int nId ) = 0;
        virtual i_variant * vt( int nId ) = 0;

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 
        // other helper function
        // 

        virtual i_variant * name_data( const char ** ppKey, char * lpszKey, int nBufSize, int * lpnSizeNeeded ) = 0;
        virtual i_variant * id_data( int * pnId ) = 0;
        virtual int name_next() = 0;
        virtual int id_next() = 0;
        virtual int reset() = 0;

        virtual int size( int * pNamePropSize, int * pIdPropSize ) = 0;
        virtual int release_all() = 0;
    };

} // xos_common

#endif // __DDEBA1E4_A5BF_41CF_8D2C_0D2BC94F37F8__
